/*
  S.M.A.C.K - An operating system kernel
  Copyright (C) 2010,2011 Mattias Holm and Kristian Rietveld
  For licensing and a full list of authors of the kernel, see the files
  COPYING and AUTHORS.
*/
#ifndef SYSCALLS_H
#define SYSCALLS_H

#include <stddef.h>
#include <sys/types.h>
#include <sys/proc.h>

struct dir_entry
{
  char name[256];
  int type;
  int size;
};

struct proc_info
{
  pid_t pid;
  uint32_t cpu_time;
};

#define TYPE_DEVICE 0
#define TYPE_MOUNT  1
#define TYPE_DATA   2
#define TYPE_DIR    3

#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2

/* System calls */
void sleep(int seconds);
int opendir(const char name[256]);
struct dir_entry *readdir(int handle);
void closedir(int handle);
void exit(int exit_code);

int open(const char name[256]);
int read(int handle, void *buff, size_t nbytes);
int write(int handle, const void *buff, size_t nbytes);
void close(int handle);
int seek(int handle, off_t offset, int whence);
int ioctl(int handle, uint32_t request, uint32_t param);

int fork(void);
int execve(const char *filename, const char *argv);

int stat(const char *filename, int *type, int *size);
int wait(int *exit_code);

int chdir(const char *directory);
void getwd(char *buffer, size_t size);

int mount(const char *fs, const char *mountpoint);

void get_processes(struct proc_info *processes, int *n_processes);

void* mmap(void *addr, size_t len, int prot, int flags, int filedes,
           off_t offset);

// Munmap ignores the len param for now
int munmap(void *addr, size_t len);

// Set and get process params, they apply to the current process only
int setprocparam(proc_param_t param, int64_t val);
int64_t getprocparam(proc_param_t param);

int mkdir(const char path[256]);
int rmdir(const char path[256]);

#endif /* SYSCALLS_H */
